package cn.zn.wx.controller;

import cn.zn.framework.common.utils.ResultBaiduSugar;
import cn.zn.modules.pz.cur.service.TpMainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <pre>
 * @projectName: finance-all
 * @packageName: cn.zn.wx.controller
 * @className: BigDataController
 * @description: 说明类用途
 * @author: zn
 * @date: 2021/7/20 9:13
 * </pre>
 */
@RestController
@RequestMapping("bigdata")
@Api(tags = "凭证大屏接口")
@Slf4j
public class BigDataController {
    @Autowired
    private TpMainService tpMainService;

    @PostMapping("pz/statistical/total")
    @ApiOperation("凭证统计-单据总量")
    public ResultBaiduSugar statistical_total() {
        Map<String, Object> map = tpMainService.queryStatistical();
        return ResultBaiduSugar.ok().put("data", map.get("pz_total"));
    }

    @PostMapping("pz/statistical/spending")
    @ApiOperation("凭证统计-请示审批中")
    public ResultBaiduSugar statistical_spending() {
        Map<String, Object> map = tpMainService.queryStatistical();
        return ResultBaiduSugar.ok().put("data", map.get("pz_audit_spending"));
    }

    @PostMapping("pz/statistical/expense")
    @ApiOperation("凭证统计-报销审签中")
    public ResultBaiduSugar statistical_expense() {
        Map<String, Object> map = tpMainService.queryStatistical();
        return ResultBaiduSugar.ok().put("data", map.get("pz_audit_expense"));
    }

    @PostMapping("pz/statistical/appoint/total")
    @ApiOperation("凭证统计-预约总数")
    public ResultBaiduSugar statistical_appoint_total() {
        Map<String, Object> map = tpMainService.queryStatistical();
        return ResultBaiduSugar.ok().put("data", map.get("appoint_total"));
    }

    @PostMapping("pz/statistical/appoint/today")
    @ApiOperation("凭证统计-今日预约")
    public ResultBaiduSugar statistical_appoint_today() {
        Map<String, Object> map = tpMainService.queryStatistical();
        return ResultBaiduSugar.ok().put("data", map.get("appoint_today"));
    }

    @PostMapping("pz/statistical/appoint/deal")
    @ApiOperation("凭证统计-预约已处理")
    public ResultBaiduSugar statistical_appoint_deal() {
        return ResultBaiduSugar.ok().put("data", tpMainService.queryAppointDeal());
    }

    @PostMapping("pz/avgForDealTime/spending")
    @ApiOperation("审批平均时间-请示")
    public ResultBaiduSugar avgForDealTime_spending() {
        return ResultBaiduSugar.ok().put("data", tpMainService.queryAvgForDealTime().get("avg_spending"));
    }

    @PostMapping("pz/avgForDealTime/expense")
    @ApiOperation("审批平均时间-报销")
    public ResultBaiduSugar avgForDealTime_expense() {
        return ResultBaiduSugar.ok().put("data", tpMainService.queryAvgForDealTime().get("avg_expense"));
    }
}
